<template>
  <div>
    <el-row class="subMenu" type="flex" justify="center" v-show="submenu">
      <el-col
        :span="3"
        :class="menuSelect ? 'btno' : 'btno-s'"
        @click.native="btnClick()"
        ><span class="bname">格里大洲</span></el-col
      >
    </el-row>
    <el-row class="subMenu" type="flex" justify="center" v-show="submenu_llpb">
      <el-col
        :span="3"
        :class="menuSelect_zfy ? 'btno_zfy' : 'btno_zfy-s'"
        @click.native="btnClick_llpb('zfy')"
        ><span class="bname_llpb">执法仪</span></el-col
      >
      <el-col
        :span="3"
        :class="menuSelect_sxt ? 'btno_sxt' : 'btno_sxt-s'"
        @click.native="btnClick_llpb('sxt')"
        ><span class="bname_llpb">摄像头</span></el-col
      >
      <el-col
        :span="3"
        :class="menuSelect_ry ? 'btno_ry' : 'btno_ry-s'"
        @click.native="btnClick_llpb('ry')"
        ><span class="bname_ry">人员</span></el-col
      >
    </el-row>
    <el-row class="bmenu">
      <el-col
        @click.native="handleclick(index)"
        :class="item.isActive ? 'active bmenubtn' : 'bmenubtn'"
        :span="4"
        v-for="(item, index) in tab"
        :key="index"
        >{{ item.name }}</el-col
      >
    </el-row>
  </div>
</template>

<script>
import Vue from "vue";
export default {
  name: "bmenu",
  data() {
    return {
      tab: [
        {
          name: "巡查走访",
          isActive: false,
        },
        {
          name: "力量排布",
          isActive: false,
        },
        {
          name: "治理态势",
          isActive: false,
        },
        {
          name: "重点项目",
          isActive: false,
        },
        {
          name: "智慧门牌",
          isActive: false,
        },
      ],
      sel: 2,
      submenu: true,
      submenu_llpb: false,
      menuSelect: true,
      menuSelect_zfy: true,
      menuSelect_sxt: true,
      menuSelect_ry: true,
    };
  },
  mounted() {
    this.tab[this.sel].isActive = true;
    Vue.prototype.index = this.sel;
  },
  methods: {
    handleclick(index) {
      Vue.prototype.index = index;
      this.tab[this.sel].isActive = false;
      this.sel = index;
      this.tab[index].isActive = true;
      index !== 3 ? this.clearimpor() : "";
      index !== 0 ? this.gsjcclear() : "";
      index !== 4 ? this.zhmpclear() : "";
      switch (index) {
        case 0:
          this.submenu = false;
          this.submenu_llpb = false;
          this.gsjcinit();
          break;
        case 1:
          this.submenu = false;
          this.submenu_llpb = false;
          this.submenu_llpb = true;
          // this.llpbinit();
          break;
        case 2:
          this.submenu_llpb = false;
          this.submenu = !this.submenu;
          break;
        case 3:
          this.submenu = false;
          this.submenu_llpb = false;
          this.impor();
          break;
        case 4:
          this.submenu = false;
          this.submenu_llpb = false;
          this.zhmpinit();
          break;
      }
    },
    btnClick() {
      this.menuSelect = !this.menuSelect;
      if (!this.menuSelect) {
        this.wgInit();
      } else {
        this.wgclear();
      }
    },
    btnClick_llpb(type) {
      if (type == "zfy") {
        this.menuSelect_zfy = !this.menuSelect_zfy;
        if (!this.menuSelect_zfy) {
          this.zfyinit();
        } else {
          this.zfyclear();
        }
      } else if (type == "sxt") {
        this.menuSelect_sxt = !this.menuSelect_sxt;
        if (!this.menuSelect_sxt) {
          this.sxtinit();
        } else {
          this.sxtclear();
        }
      } else if (type == "ry") {
        this.menuSelect_ry = !this.menuSelect_ry;
        if (!this.menuSelect_ry) {
          this.ryinit();
        } else {
          this.ryclear();
        }
      }
    },
  },
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.bmenu {
  width: 1683px;
  height: 139px;
  position: absolute;
  left: 700px;
  top: 1080px;
  background-image: url(../../assets/image/global/bmenu.png);
  background-position: center;
  background-repeat: no-repeat;
  background-size: 100% 120%;
  padding-left: 503px;
  padding-top: 60px;
}
.btno {
  position: relative;
  background-image: url(../../assets/image/global/submenu.png);
  background-position: center;
  background-repeat: no-repeat;
  background-size: 100% 100%;
}
.btno-s {
  position: relative;
  background-image: url(../../assets/image/global/submenu-s.png);
  background-position: center;
  background-repeat: no-repeat;
  background-size: 100% 100%;
}
.btno_zfy {
  position: relative;
  background-image: url(../../assets/image/global/submenu_zfy.png);
  background-position: center;
  background-repeat: no-repeat;
  background-size: 100% 100%;
}
.btno_zfy-s {
  position: relative;
  background-image: url(../../assets/image/global/submenu_zfy-s.png);
  background-position: center;
  background-repeat: no-repeat;
  background-size: 100% 100%;
}
.btno_sxt {
  position: relative;
  background-image: url(../../assets/image/global/submenu_sxt.png);
  background-position: center;
  background-repeat: no-repeat;
  background-size: 100% 100%;
}
.btno_sxt-s {
  position: relative;
  background-image: url(../../assets/image/global/submenu_sxt-s.png);
  background-position: center;
  background-repeat: no-repeat;
  background-size: 100% 100%;
}
.btno_ry {
  position: relative;
  background-image: url(../../assets/image/global/submenu_ry.png);
  background-position: center;
  background-repeat: no-repeat;
  background-size: 100% 100%;
}
.btno_ry-s {
  position: relative;
  background-image: url(../../assets/image/global/submenu_ry-s.png);
  background-position: center;
  background-repeat: no-repeat;
  background-size: 100% 100%;
}
.bname {
  position: absolute;
  bottom: 4px;
  color: white;
  left: 15px;
  font-size: 20px;
}
.bname_llpb {
  position: absolute;
  bottom: 4px;
  color: white;
  left: 24px;
  font-size: 20px;
}
.bname_ry {
  position: absolute;
  bottom: 4px;
  color: white;
  left: 34px;
  font-size: 20px;
}
.subMenu {
  width: 883px;
  height: 110px;
  position: absolute;
  left: 1110px;
  top: 1000px;
  /* border: 1px dotted white; */
}
.el-row .active {
  background-image: url(../../assets/image/global/bmenu_item_active.png);
}
.bmenubtn {
  width: 140px;
  height: 64px;
  background-image: url(../../assets/image/global/bmenu_item.png);
  background-position: center;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  text-align: center;
  line-height: 64px;
  font-size: 18px;
  color: #fff;
  cursor: pointer;
}
</style>
